package it.getta.vicinometro.utils;

import android.location.Criteria;

public class CriteriaFactory {

	public static final int FINEST_CRITERIA = 0;
	public static final int FINE_CRITERIA = 1;
	public static final int COARSE_CRITERIA = 2;
	public static final int COARSEST_CRITERIA = 3;
	public static final int LOCATION_CRITERIA = 4;

	public static Criteria getCriteria(int criteriaType) {
		Criteria criteria = new Criteria();

		switch (criteriaType) {
		case FINEST_CRITERIA:

			criteria.setAccuracy(Criteria.ACCURACY_FINE);
			criteria.setSpeedRequired(true);
			criteria.setAltitudeRequired(true);
			criteria.setBearingRequired(true);
			criteria.setCostAllowed(true);
			criteria.setPowerRequirement(Criteria.POWER_HIGH);

			break;

		case FINE_CRITERIA:

			criteria.setAccuracy(Criteria.ACCURACY_FINE);
			criteria.setSpeedRequired(true);
			criteria.setAltitudeRequired(true);
			criteria.setBearingRequired(false);
			criteria.setCostAllowed(true);
			criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
			break;

		case COARSE_CRITERIA:

			criteria.setAccuracy(Criteria.ACCURACY_FINE);
			criteria.setSpeedRequired(true);
			criteria.setAltitudeRequired(false);
			criteria.setBearingRequired(false);
			criteria.setCostAllowed(false);
			criteria.setPowerRequirement(Criteria.POWER_LOW);
			break;

		case COARSEST_CRITERIA:
			criteria.setAccuracy(Criteria.ACCURACY_COARSE);
			criteria.setSpeedRequired(false);
			criteria.setAltitudeRequired(false);
			criteria.setBearingRequired(false);
			criteria.setCostAllowed(false);
			criteria.setPowerRequirement(Criteria.POWER_LOW);
			break;
			
		case LOCATION_CRITERIA:
			criteria.setAccuracy(Criteria.ACCURACY_FINE);
			criteria.setSpeedRequired(false);
			criteria.setAltitudeRequired(false);
			criteria.setBearingRequired(false);
			criteria.setCostAllowed(false);
			criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
			break;

		default:
			criteria = null;
			break;
		}

		return criteria;
	}

}
